# coding:utf-8

import logging,time,os

class commonLog(logging.Logger):
    '''
    custom logger class with additional levels and methods
    '''

    def __init__(self, name):
        logging.Logger.__init__(self, name, logging.INFO)  # 实例化一个logger
        now = time.strftime('%Y%m%d%H%M%S',time.localtime())
        print now
        fileHandle = logging.FileHandler('../logs/{}.log'.format(now))  # 设置log文件输出
        console = logging.StreamHandler()  # 设置控制台输出
        console.setLevel(logging.INFO)
        formatter = logging.Formatter("[%(levelname)s]%(asctime)s [%(funcName)s: %(filename)s,%(lineno)d] %(message)s")
        fileHandle.setFormatter(formatter)
        console.setFormatter(formatter)
        self.addHandler(fileHandle)
        self.addHandler(console)
        return



